package com.yunji.bid.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunji.bid.entity.TBid;
import com.yunji.bid.query.QueryBid;
import com.yunji.bid.service.TBidService;
import com.yunji.common.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 宝贝投资
 * @since 2020-02-14
 */
@RestController
@RequestMapping("/t-bid")
@Api(tags = "投标模块")
public class TBidController {


    @Autowired
    private TBidService tBidService;


    @GetMapping("selectPageBid")
    @ApiOperation(value = "分页投资列表")
    public R selectPageBid(
            @ApiParam(name="queryBid",value="查询对象",required=false)QueryBid queryBid,

            @ApiParam(name = "page", value = "当前页码", required = true)
            @RequestParam Integer page,

            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @RequestParam Integer limit
    ){
        Page<TBid> pageParam=new Page<>(page,limit);
        tBidService.selectPageBid(pageParam,queryBid);
        return R.ok().data("listData",pageParam.getRecords()).data("currentPage",pageParam.getCurrent()).data("pageSize",pageParam.getPages());
    }
    @GetMapping("getByBorrowId")
    @ApiOperation(value = "查询投标列表")
    public R getByBorrowId(
            @ApiParam(name = "borrowId", value = "借款标id", required = true)
            @RequestParam Integer borrowId
    ){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("borrow_id",borrowId);
        List list = tBidService.list(queryWrapper);
        return R.ok().data("data",list);
    }

    @RequestMapping("add")
    @ApiOperation(value = "添加发起投标")
    public R addBid(
            @ApiParam(name = "borrowId", value = "toubiao", required = true)
            @RequestParam Integer borrowId
    ){
        return R.ok();
    }
}

